package com.nine.pattern.builder.demo2;

/**
 * @author nine
 * @version 1.0
 * @description TODO
 * @date 2024-07-04 20:52
 */
public class Phone {

	private String cpu;
	private String screen;
	private String memory;
	private String mainboard;

	// 私有构造
	private Phone(Builder builder) {
		this.cpu = builder.cpu;
		this.screen = builder.screen;
		this.memory = builder.memory;
		this.mainboard = builder.mainboard;
	}

	@Override
	public String toString() {
		return "Phone{" + "cpu='" + cpu + '\'' + ", screen='" + screen + '\'' + ", memory='" + memory + '\'' + ", " + "mainboard='" + mainboard + '\'' + '}';
	}

	public static final class Builder {

		private String cpu;
		private String screen;
		private String memory;
		private String mainboard;

		public Builder cpu(String cpu) {
			this.cpu = cpu;
			return this;
		}

		public Builder screen(String screen) {
			this.screen = screen;
			return this;
		}

		public Builder memory(String memory) {
			this.memory = memory;
			return this;
		}

		public Builder mainboard(String mainboard) {
			this.mainboard = mainboard;
			return this;
		}

		// 使用构建者创建 Phone 对象
		public Phone build() {
			return new Phone(this);
		}

	}


}
